package com.unitedats.Project.DB;

import java.util.List;

import com.unitedats.Project.Entity.PmProject;
import com.unitedats.common.util.DBManager;

public class DBQueryManager {

	DBManager dbm;

	public DBQueryManager(DBManager dbm) {

		this.dbm = dbm;
	}

	public List<PmProject> searchForProject(String name, String code, int type, int status) {
		String sqlQuery = "SELECT NAME , CODE , STATUS_ID , TYPE_ID FROM pm_project  WHERE ";

		String sqlCondition = "";

		if (name != null && !name.isEmpty())
			sqlCondition += " name like '%" + name + "%'  ";

		if (code != null && !code.isEmpty()) {
			if (!sqlCondition.isEmpty())
				sqlCondition += " or ";
			sqlCondition += " code like '%" + name + "%'  ";
		}
		
		if (type !=0) {
			if (!sqlCondition.isEmpty())
				sqlCondition += " or ";
			sqlCondition += " type_id = "+type +" " ;
		}

		
		if (status !=0) {
			if (!sqlCondition.isEmpty())
				sqlCondition += " or ";
			sqlCondition += " status_id = "+status +" " ;
		}
		return null;

	}

}
